package org.telegram.bot.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.telegram.bot.domain.BotMenu;
import org.telegram.bot.mapper.BotMenuMapper;
import org.telegram.bot.service.IBotMenuService;

import java.util.Arrays;
import java.util.List;

/**
 * Bot菜单Service业务层处理
 *
 * @author wyx
 * @date 2023-05-31
 */
@Slf4j
@Service
public class BotMenuServiceImpl implements IBotMenuService
{
    @Autowired
    private BotMenuMapper botMenuMapper;

    /**
     * 查询Bot菜单
     *
     * @param id Bot菜单主键
     * @return Bot菜单
     */
    @Override
    public BotMenu selectBotMenuById(Long id)
    {
        return botMenuMapper.selectById(id);
    }

    /**
     * 查询Bot菜单列表
     *
     * @param botMenu Bot菜单
     * @return Bot菜单
     */
    @Override
    public List<BotMenu> selectBotMenuList(BotMenu botMenu)
    {
        return botMenuMapper.selectBotMenuList(botMenu);
    }

    /**
     * 新增Bot菜单
     *
     * @param botMenu Bot菜单
     * @return 结果
     */
    @Override
    public int insertBotMenu(BotMenu botMenu)
    {
        return botMenuMapper.insert(botMenu);
    }

    /**
     * 修改Bot菜单
     *
     * @param botMenu Bot菜单
     * @return 结果
     */
    @Override
    public int updateBotMenu(BotMenu botMenu)
    {
        return botMenuMapper.updateById(botMenu);
    }

    /**
     * 批量删除Bot菜单
     *
     * @param ids 需要删除的Bot菜单主键
     * @return 结果
     */
    @Override
    public int deleteBotMenuByIds(Long[] ids)
    {
        return botMenuMapper.deleteByIds(Arrays.asList(ids));
    }
    
    private Long getIdByCode(String code){
        return botMenuMapper.selectIdByCode(code);
    }

}
